<html>
<head><meta charset="utf-8"><title>remove #![crate_type] · edition 2021 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/index.html">edition 2021</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html">remove #![crate_type]</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225405492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/remove%20%23%21%5Bcrate_type%5D/near/225405492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html#225405492">(Feb 06 2021 at 11:24)</a>:</h4>
<p><code>#![crate_type]</code> is rarely used as far as I know given that it conflicts with cargo. It does however use quite a lot of code to get the attribute after the session has already been created: <a href="https://github.com/rust-lang/rust/blob/c4e33b51c1a2d5e599b949fa3006467b88df253a/compiler/rustc_interface/src/passes.rs#L171">https://github.com/rust-lang/rust/blob/c4e33b51c1a2d5e599b949fa3006467b88df253a/compiler/rustc_interface/src/passes.rs#L171</a>, <a href="https://github.com/rust-lang/rust/blob/c4e33b51c1a2d5e599b949fa3006467b88df253a/compiler/rustc_interface/src/util.rs#L560-L610">https://github.com/rust-lang/rust/blob/c4e33b51c1a2d5e599b949fa3006467b88df253a/compiler/rustc_interface/src/util.rs#L560-L610</a> Finally <code>-Zno-link</code>/<code>-Zlink-only</code> doesn't support it. For these reasons I think it should just completely be removed in the next edition.</p>



<a name="225413918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/remove%20%23%21%5Bcrate_type%5D/near/225413918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Julian-Wollersberger <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html#225413918">(Feb 06 2021 at 14:16)</a>:</h4>
<p>But older editions would have to still support it, so the code would have to stay anyway, right?<br>
Editions are not a mechanism to reduce technical dept, they increase it.</p>
<p>Maybe <code>#![crate_type]</code> could be deprecated for all editions, and eventually removed, if it is used rarely enough.</p>
<p>([https://doc.rust-lang.org/reference/linkage.html]  for reference)</p>



<a name="225586885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/remove%20%23%21%5Bcrate_type%5D/near/225586885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html#225586885">(Feb 08 2021 at 18:27)</a>:</h4>
<p>I would say it's potentially worth deprecating -- it can help to make it used less, which may let us remove it eventually</p>



<a name="225586977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/remove%20%23%21%5Bcrate_type%5D/near/225586977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html#225586977">(Feb 08 2021 at 18:28)</a>:</h4>
<p>but also it sends a signal to other sorts of tooling</p>



<a name="225802497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/remove%20%23%21%5Bcrate_type%5D/near/225802497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html#225802497">(Feb 10 2021 at 07:40)</a>:</h4>
<p>I’ve just seen crate_type in <a href="https://github.com/tock/tock/blob/master/chips/sam4l/src/lib.rs">this</a>, but I think this usage could be moved to the Cargo.toml without problems</p>



<a name="225802515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/remove%20%23%21%5Bcrate_type%5D/near/225802515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/remove.20.23!.5Bcrate_type.5D.html#225802515">(Feb 10 2021 at 07:41)</a>:</h4>
<p>So the attribute is used, but for crates already using cargo this could be an automatic fix maybe ?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>